package gwtmodule1.client.gui.stock;

import gwtmodule1.client.gui.stock.PageSubcategoryList.SubcategoryParams;
import gwtmodule1.client.gui.utils.DekoTable;
import gwtmodule1.client.gui.utils.FrameClient;
import gwtmodule1.client.gui.utils.FrameProvider;
import gwtmodule1.client.gui.utils.SwitchPage;
import gwtmodule1.client.gui.utils.Title;

import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class PageCategoryList extends VerticalPanel implements FrameClient {

	private class CategoryTable extends DekoTable {

		public CategoryTable() {
			super();
			addTitle("Category");
		}

		public void addItem(int catID, String name) {
			Hyperlink l = new Hyperlink(name, "Category" + catID);
			SubcategoryParams param = new SubcategoryParams(catID, name);
			l.addClickListener(new SwitchPage(provider, pageSubcategoryList,
					param));
			addRow().add(l);
		}

	}

	private FrameProvider provider;

	private PageSubcategoryList pageSubcategoryList;

	public PageCategoryList(FrameProvider provider) {
		this.provider = provider;
		pageSubcategoryList = new PageSubcategoryList(provider);
		add(new Title("Select Category"));
		add(createTable());
	}

	private Widget createTable() {
		CategoryTable table = new CategoryTable();
		table.addItem(0, "Electronics");
		table.addItem(0, "Movies");
		table.addItem(0, "Food");
		return table;
	}

	public void onShow(Object param) {
	}

}
